package com.zhoug.zmuidemo.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.zhoug.zmui.ZMUIRoundIndicatorView;
import com.zhoug.zmui.navigation.ZMUINavigationGroup;
import com.zhoug.zmuidemo.R;

public class NavigationActivity extends AppCompatActivity {
    private ZMUINavigationGroup mFooter;
    private TextView mTextView;
    private ZMUIRoundIndicatorView mIndicatorView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_navigation);
        findViews();
        mTextView.setText("页面1");
        mFooter.setSelected(0);
        mIndicatorView.setSelection(0);
        mFooter.setOnSelectedListener(new ZMUINavigationGroup.OnSelectedListener() {
            @Override
            public void onSelected(int oldSelected, int newSelected) {
                if(oldSelected!=newSelected){
                    mTextView.setText("页面"+(newSelected+1));
                }else{
                    mTextView.setText("重复选中页面"+(newSelected+1));
                }
                Toast.makeText(NavigationActivity.this, oldSelected+"->"+newSelected, Toast.LENGTH_SHORT).show();
                mIndicatorView.setSelection(newSelected);
            }
        });
    }

    private void findViews() {
        mFooter = findViewById(R.id.footer);
        mTextView = findViewById(R.id.textView);
        mIndicatorView = findViewById(R.id.indicatorView);
    }
}